package com.mjr.webmanage.mapper;

import com.mjr.webmanage.pojo.Emp;
import com.mjr.webmanage.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {


    @Select("select emp.* ,dept.name deptName from emp left join dept on emp.dept_id = dept.id")
    List<Emp> list(Integer page, Integer pageSize);

    List<Emp> list2(EmpQueryParam empQueryParam);


    @Options(useGeneratedKeys = true, keyProperty = "id") // //需要获取数据库自动增长的主键，并赋值给emp对象的id属
    @Insert("insert into emp (username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) values " + "(#{username},#{name},${gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);


    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void update(Emp emp);


    @MapKey("pos")
    List<Map> getJobData();


    @MapKey("gender")
    public List<Map> getGenderData();

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp getByUsernameAndPassword(Emp emp);
}
